package edu.ncsu.csc.csc454.project.gui.info_panel;

import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

import edu.ncsu.csc.csc454.project.resources.Constants;

/**
 * @author Team AW
 * @version 0.1
 */
@SuppressWarnings("serial")
public class InfoPanel extends JPanel {

    private BufferedImage    mbImage;

    private TowerBars        bars;

    private BatteryIndicator batteryIndicator;

    public InfoPanel() {
        setOpaque(false);
        setLayout(new FlowLayout(FlowLayout.TRAILING, 1, 5));

        createBackground();
        createBars();
        createBatteries();
    }

    private void createBackground() {
        try {
            mbImage = ImageIO.read(new File(Constants.MBIMAGE_PATH));
        } catch (IOException e) {}
    }

    private void createBars() {
        bars = new TowerBars();
        add(bars);
    }

    private void createBatteries() {
        batteryIndicator = new BatteryIndicator();
        add(batteryIndicator);
    }

    @Override
    public void paintComponent(Graphics gX) {
        super.paintComponent(gX);
        ((Graphics2D) gX).drawImage(mbImage, null, 0, 0);
    }
}
